#ifndef REPORT_TIMER
#define REPORT_TIMER
#include <map>
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
class TimerElementInterface
{
public:
    TimerElementInterface(){};
    virtual ~TimerElementInterface(){};
    virtual void TimeOutCallBack() = 0;

};

template<class T>
class TimerElement:public TimerElementInterface
{
public:
    typedef void (T::*Hook)();
    TimerElement(T *obj, Hook h):
    obj_(obj),
    hook_(h)
    {
    };

    virtual void TimeOutCallBack()
    {
        (obj_->*hook_)();
    }

private:
    T *obj_;
    Hook hook_;

};

#define TimerPtr Timer::ptr()
class Timer
{
public:
    static Timer *ptr();
    bool initialize();
    bool unintialize();
    bool queue(uint32_t timeIntvl, TimerElementInterface *element);
    bool dequeue(TimerElementInterface *element);
    bool intializeState();
    void handleTick();

private:
    Timer();
    Timer(const Timer&);
    Timer& operator=(const Timer&);
    bool inializedM;
    enum {perSecond = 100};

    typedef std::map<TimerElementInterface* , uint32_t> TimerType;
    TimerType elements_;
   
};

inline Timer* Timer::ptr()
{ 
    static Timer timer_;
    return &timer_;
}



#endif

